home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / ispell40.lha / ispell-4.0 / util.c < prev    next >
C/C++ Source or Header  |  1993-04-16  |  1KB  |  54 lines

  1. /* Copyright (C) 1990, 1993 Free Software Foundation, Inc.
  2.  
  3.    This file is part of GNU ISPELL.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include <stdio.h>
  20.  
  21. #ifdef HAVE_MALLOC_H
  22. #include <malloc.h>
  23. #endif
  24.  
  25. #include "ispell.h"
  26.  
  27.  
  28. /* Allocate NBYTES bytes of memory */
  29.  
  30. void *
  31. xmalloc (nbytes)
  32.   int nbytes;
  33. {
  34.   void *tmp = (void *) malloc (nbytes);
  35.  
  36.   if (!tmp)
  37.     fprintf (stderr, "out of memory: can't allocate %d bytes\n", nbytes);
  38.  
  39.   return tmp;
  40. }
  41.  
  42.  
  43. /* Allocate NBLOCKS of NBYTES bytes of cleared memory */
  44.  
  45. void *
  46. xcalloc (nblocks, nbytes)
  47.   int nblocks, nbytes;
  48. {
  49.   void *tmp = (void *) xmalloc (nblocks * nbytes);
  50.  
  51.   bzero (tmp, nblocks * nbytes);
  52.   return tmp;
  53. }
  54.